import { createRouter, createWebHashHistory } from 'vue-router'
//关于登录注册，修改密码的页面组件
import Login from '../views/login/Login.vue'
import Register from '../views/login/Register.vue'
import ResetPws from '../views/login/ResetPws.vue'
import PwsLogin from '@/views/login/PwsLogin.vue'
//导入首页
import Home from '../views/home/Home.vue'
import List from '../views/home/List.vue'
import Cart from '../views/home/Cart.vue'
import My from '../views/home/My.vue'
//搜索页
import Search from '@/views/search/Search.vue'
import SearchIndex from '@/views/search/SearchIndex.vue'
import SearchList from '@/views/search/SearchList.vue'
//商品
import Detail from "@/views/goods/Details.vue"
import Order from "@/views/goods/Order.vue"
//我的地址
import AddressIndex from '@/views/address/AddressIndex.vue'
import AddressList from '@/views/address/AddressList.vue'
import Address from '@/views/address/Address.vue'

const routes = [
    { path: '/home', component: Home, },
    { path: '/', redirect: '/home' },
    { path: '/list', component: List },
    { path: '/cart/:token', component: Cart },
    { path: '/my', component: My },
    { path: '/login', component: Login },
    { path: '/pwsLogin', component: PwsLogin },
    { path: '/register', component: Register },
    { path: '/resetPws', component: ResetPws },
    {
        path: '/address',
        component: Address,
        name: 'Address',
        children: [
            { path: 'addressIndex', name: 'AddressIndex', component: AddressIndex },
            { path: 'addPath', name: 'AddressList', component: AddressList },
        ],
    },
    {
        path: '/search',
        name: 'Search',
        component: Search,
        children: [
            { path: 'searchindex', name: 'index', component: SearchIndex },
            { path: 'searchlist', name: "list", component: SearchList }
        ]
    },
    { path: '/detail/:id', component: Detail },
    { path: '/order', name: 'Order', component: Order },

]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router